const Sequelize = require('sequelize');

/**
 * 创建数据库连接
 * @param  {[type]} options.name     [数据库名]
 * @param  {[type]} options.user     [用户]
 * @param  {[type]} options.password [密码]
 * @param  {[type]} options.host     [地址]
 * @param  {[type]} options.port     [端口]
 * @param  {[type]} options.dialect  [数据库类型]
 * @return {[type]}                  [description]
 */
const create = function({ name, user, password, host, port, dialect }) {
    return new Sequelize(
        name,
        user,
        password, {
            host,
            port,
            dialect,
            define: {
                timestamps: true, // will create columns (updatedAt, createdAt)
            },
            pool: {
                max: 10,
                min: 0,
                acquire: 30000
            },
            timezone: '+08:00',
            operatorsAliases: false
        });
}


module.exports = {
    create
}